package utils

import (
	"fmt"
	"gopkg.in/ini.v1"
)

var (
	AppMode string
	HttpPort string
	JwtKey string

	Db  string
	DbHost string
	DbPost string
	DbUser string
	DbPassWord string
	DbName string

	AccessKey  string
	SecretKey  string
	Bucket  string
	QiniuServe string

)

func init()  {
	file,err :=ini.Load("config/config.ini")
	if err !=nil{
		fmt.Println("配置文件错误：",err)
	}
	LoadServer(file)
	LoadData(file)
	LoadQiniu(file)
}

func LoadServer(file *ini.File)  {
	AppMode = file.Section("server").Key("AppMode").MustString("debug")
	HttpPort = file.Section("server").Key("HttpPort").MustString(":3000")
	JwtKey = file.Section("server").Key("JwtKey").MustString("9er56de879")

}

func LoadData(file *ini.File)  {
	Db =  file.Section("database").Key("Db").MustString("debug")
	DbHost = file.Section("database").Key("DbHost").MustString("127.0.0.1")
	DbPost = file.Section("database").Key("DbPost").MustString("3306")
	DbUser = file.Section("database").Key("DbUser").MustString("root")
	DbPassWord = file.Section("database").Key("DbPassWord").MustString("root")
	DbName =  file.Section("database").Key("DbName").MustString("ginblog")

}

func LoadQiniu(file *ini.File){
	AccessKey =  file.Section("qiniu").Key("AccessKey").String()
	SecretKey =  file.Section("qiniu").Key("SecretKey").String()
	Bucket =  file.Section("qiniu").Key("Bucket").String()
	QiniuServe =  file.Section("qiniu").Key("QiniuServe").String()


}
